# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Sebastian Lau <archlinux _at_ slau _dot_ info>
# Contributor: Eric Ozwigh <ozwigh at gmail dot com>

pkgname=veracrypt
_pkgname=VeraCrypt
pkgver=1.25.9
pkgrel=4
pkgdesc='Disk encryption with strong security based on TrueCrypt'
url='https://www.veracrypt.fr/'
arch=('loong64' 'x86_64')
license=('custom:TrueCrypt')
depends=('fuse2>=2.8.0' 'wxwidgets-gtk3>=3.2' 'libsm' 'device-mapper')
optdepends=('sudo: mounting encrypted volumes as nonroot users')
makedepends=('yasm')
source=(https://launchpad.net/veracrypt/trunk/${pkgver}/+download/VeraCrypt_${pkgver}_Source.tar.bz2{,.sig}
        no-makeself.patch
        veracrypt.desktop
        wx-3.2-size-warnings.patch)
sha512sums=('9b11c8d8e85770ae05960fef8fc9639731e4f9caf0cc4e50bc8c9c92b45d44c80eaeff483d3ab048fd6a82cc873a6027820e21abde7ddb92b3c368f85b837cf2'
            'SKIP'
            '40c269859bb97fbcceb443e5f457788bac650271ed118ec79d34f56fc340ad6e613114fe905ec5aba8c4d171c51c9a6865f97e9fa1ba01fa98ef18be4e97bbe1'
            'f689ca64bac7042030de7714aed8cc89f2c5f87b407444b1b121491c1d89c147babaaa454ddc2a93b70ae20d4da59f96ad64f01b04bea9017d658c377faeb75d'
            '5ff99e8d8569d36ff0e2e3b9fd85f59f5b3de98e3f5cda7ee85a6688a33a10d4527b0fed08e53812b28ea2b42ed88481455b5f1454870e35940b2e49bf59b5b2')
validpgpkeys=('5069A233D55A0EEB174A5FC3821ACD02680D16DE') # VeraCrypt Team <veracrypt@idrix.fr>

prepare() {
  cd src
  chmod -R u+w . # WAT award
  patch -Np1 < "${srcdir}/no-makeself.patch"
  patch -p1 < ../wx-3.2-size-warnings.patch # https://github.com/veracrypt/VeraCrypt/issues/952
}

build() {
  cd src
  make PKG_CONFIG_PATH=/usr/lib/pkgconfig \
    TC_EXTRA_LFLAGS+="-ldl ${LDFLAGS}" \
    TC_EXTRA_CXXFLAGS="${CXXFLAGS} ${CPPFLAGS}" \
    TC_EXTRA_CFLAGS="${CFLAGS} ${CPPFLAGS}"
}

package() {
  cd src
  install -Dm 755 Main/${pkgname} "${pkgdir}/usr/bin/${pkgname}"
  install -Dm 644 "${srcdir}/veracrypt.desktop" -t "${pkgdir}/usr/share/applications"
  install -Dm 644 Resources/Icons/VeraCrypt-256x256.xpm "${pkgdir}/usr/share/pixmaps/veracrypt.xpm"
  install -Dm 644 License.txt -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim: ts=2 sw=2 et:
